<!--
 * @Author: your name
 * @Date: 2019-10-25 20:13:05
 * @LastEditTime: 2019-10-26 15:53:57
 * @LastEditors: Please set LastEditors
 * @Description: In License Settings Edit
 * @FilePath: \simple\src\views\demo\Record\licenseRecord.vue
 -->
<template>
  <d2-container better-scroll>
    <!-- 头部搜索部分 -->
    <template slot="header">
      <el-form :inline="true" size="mini" style="margin-bottom: -18px;">
          <el-form-item label="号牌号码:" prop="brandNumber">
              <el-input v-model="brandNumber" placeholder="号牌号码" style="width: 140px;"  clearable />
          </el-form-item>

          <el-form-item>
              <el-button type="primary" @click="searchByBrandNumber">
                  <d2-icon name="search" /> 查询
              </el-button>
          </el-form-item>

          <el-form-item>
              <el-button @click="searchReset">
                  <d2-icon name="refresh" /> 重置
              </el-button>
          </el-form-item>
          <!-- <el-form-item label="路线:" prop="brandNumber">
              <el-input v-model="brandNumber" placeholder="起点" style="width: 140px;"  clearable /> -
              <el-input v-model="brandNumber" placeholder="终点" style="width: 140px;"  clearable />
          </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="searchByBrandNumber">
                  <d2-icon name="search" /> 查询
              </el-button>
          </el-form-item> -->
      </el-form>
    </template>
    <licenseApplicationList :applyList="applyList"/>
    <!-- 尾部页码显示 -->
    <template slot="footer">
     <pagination @getApplyList="getApplyList" :total="total"/>
    </template>
  </d2-container>
</template>

<script>
import licenseApplicationList from '@/components/licenseApplicationList'
import pagination from '@/components/pagination'
import { getAllLicenseApplication, searchByBrandNumber } from '@/api/licenseApplication'
export default {
  name: 'record-licenseRecord',
  data () {
    return {
      brandNumber: '',
      id: 1,
      total: 0,
      current: 1,
      size: 8,
      thStyle: {
        fontSize: '16px'
      },
      applyList: []
    }
  },
  created () {
    this.getApplyList(this.size, this.current)
  },
  methods: {
    getApplyList (size, current) {
      getAllLicenseApplication({ pageNum: current, pageSize: size }).then(res => {
        console.log('getAllLicenseApplication: ', res)
        this.applyList = res.list
        this.total = res.total
      }).catch(err => {
        console.log('err', err)
      })
    },
    searchByBrandNumber () {
      searchByBrandNumber({ pageNum: this.current, pageSize: this.size, plateNo: this.brandNumber }).then(res => {
        console.log('searchByBrandNumber: ', res)
        this.applyList = res.list
        this.total = res.total
      }).catch(err => {
        console.log('err', err)
      })
    },
    searchReset () {
      this.getApplyList(this.size, this.current)
      this.brandNumber = ''
    }
  },
  components: {
    licenseApplicationList,
    pagination
  }
}
</script>

<style>

</style>
